$(document).ready(function(){
    var flagyhw,flagsz,flagdqt,flagyyb,flagywr,flagfz,flagyw,flagdyb,flaglyb,flagfz1,flagyw1,flagdyb1;
    var pagnumyhw,pagnumsz,pagnumdqt,pagnumyyb,pagnumywr,pagnumfz,pagnumyw,pagnumdyb,pagnumlyb,pagnumfz1,pagnumyw1,pagnumdyb1;
    var flagnumsyhw=new Array();
    var flagnumssz=new Array();
    var flagnumsdqt=new Array();
    var flagnumsyyb=new Array();
    var flagnumsywr=new Array();
    var flagnumsfz=new Array()
    var flagnumsyw=new Array();
    var flagnumsdyb=new Array();
    var flagnumslyb=new Array();
    var flagnumsfz1=new Array()
    var flagnumsyw1=new Array();
    var flagnumsdyb1=new Array();
    var images,imagelength,buttonID;
    var str = "http://fish.yfi.ac.cn:80/Fish/picture/";//http:fish.yfi.ac.cn:80/Fish/picture/CTH20170923163446/0.jpeg
    $("#yyb").draggable();
    $("#lyb").draggable();
    //测点
    $('.point-list-title').click(function(selected){
        $("#addWLE").show();
        $("#WLEupper").hide();
        $("#WLEmiddle").hide();
        $("#WLElow").hide();
        $("#WLEmix").hide();
        $("#huaxian").show();
        var children = $(this).children().first();
        if(children.hasClass('glyphicon-triangle-right')){
            children.removeClass('glyphicon-triangle-right');
            children.addClass('glyphicon-triangle-bottom');
        }else{
            children.removeClass('glyphicon-triangle-bottom');
            children.addClass('glyphicon-triangle-right');
        }
        $(this).next().slideToggle();
        $.ajax({
            type: "get",
            url: "ShowMessage.action?monitID=" + testnodeid,
            async: true,
            success: function (result) {
                MonitArr = result.split(',');
                $("#add-Dot input").each(function () {
                    $(this).val("");
                });
                var dataArray = result.split("_");
                MonitArr = dataArray[0].split(",");

                $("#add-Dot input").each(function (i, n) {
                    $(this).val(MonitArr[i + 1]);

                });
                $("#WLEupper input").each(function () {
                    $(this).val("");
                });
                /*
                $("#WLEupper").hide();
                $("#WLEmiddle").hide();
                $("#WLElow").hide();
                $("#WLEmix").hide();
                if (userName != "privilege") {
                    $("#addWLEupper").show();
                    $("#addWLEmiddle").show();
                    $("#addWLElow").show();
                    $("#addWLEmix").show();
                }*/
                if ($("#user3").val() != "privilege") {
                    $("#caiyangshang").html("采样水层上&nbsp;<button id=\"addWLEupper\" class=\"btn btn-primary\" style=\"float:right;margin-right:20%;\"><span\n" +
                        "                                        class=\"glyphicon glyphicon-plus\"></span>&nbsp添加采样水层</button>");
                    $("#caiyangzhong").html("采样水层中&nbsp;<button id=\"addWLEmiddle\" class=\"btn btn-primary\" style=\"float:right;margin-right:20%;\"><span\n" +
                        "                                        class=\"glyphicon glyphicon-plus\"></span>&nbsp添加采样水层</button>");
                    $("#caiyangxia").html("采样水层下&nbsp;<button id=\"addWLElow\" class=\"btn btn-primary\" style=\"float:right;margin-right:20%;\"><span\n" +
                        "                                        class=\"glyphicon glyphicon-plus\" ></span>&nbsp添加采样水层</button>");
                    $("#caiyanghunhe").html("混合采样&nbsp;<button id=\"addWLEmix\" class=\"btn btn-primary\" style=\"float:right;margin-right:20%;\"><span\n" +
                        "                                        class=\"glyphicon glyphicon-plus\"></span>&nbsp添加混合采样");
                }
                for (var k = 1; k < dataArray.length; k++) {
                    MonitArr = dataArray[k].split(",");
                    if (MonitArr[1] == "上") {
                        WLEID1 = MonitArr[0];

                        $("#caiyangshang").html("<span ></span> " + "采样水层上:" + MonitArr[0]);
                        if ($("#user3").val() != "privilege") {
                            $("#caiyangshang").html("<span ></span> " + "采样水层上:" + MonitArr[0] + "&nbsp;&nbsp;&nbsp;<button  id=\"updateWLEupper\" style=\"float:right;margin-right:16%;\">修改</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"deleteWLEupper\" class=\"btn-danger\" style=\"float:right;margin-right:13%;\">删除</button>");
                        }
                        $("#WLEupper input").each(function (i, n) {
                            if (i > 3) return;
                            $(this).val(MonitArr[i + 2]);
                        });
                        $("#WLEupper").show();
                    } else if (MonitArr[1] == "中") {
                        WLEID2 = MonitArr[0];
                        $("#caiyangzhong").html("<span ></span> " + "采样水层中:" + MonitArr[0]);
                        if ($("#user3").val() != "privilege") {
                            $("#caiyangzhong").html("<span ></span> " + "采样水层中:" + MonitArr[0] + "<button id=\"updateWLEmiddle\" style=\"float:right;margin-right:16%;\">修改</button>&nbsp;&nbsp;&nbsp; <button id=\"deleteWLEmiddle\" class=\"btn-danger\" style=\"float:right;margin-right:13%;\">删除</button>&nbsp;&nbsp;&nbsp;");
                        }
                        $("#WLEmiddle input").each(function () {
                            $(this).val("2");
                        });
                        $("#WLEmiddle input").each(function (i, n) {
                            if (i > 3) return;
                            $(this).val(MonitArr[i + 2]);
                        });
                        $("#WLEmiddle").show();
                    } else if (MonitArr[1] == "下") {
                        WLEID3 = MonitArr[0];
                        $("#caiyangxia").html("<span ></span> " + "采样水层下:" + MonitArr[0]);
                        if ($("#user3").val() != "privilege") {
                            $("#caiyangxia").html("<span ></span> " + "采样水层下:" + MonitArr[0] + "&nbsp;&nbsp;&nbsp;<button id=\"updateWLElow\" style=\"float:right;margin-right:16%;\">修改</button>&nbsp;&nbsp;&nbsp;<button id=\"deleteWLElow\" class=\"btn-danger\" style=\"float:right;margin-right:13%;\">删除</button> ");
                        }
                        $("#WLElow input").each(function () {
                            $(this).val("3");
                        });
                        $("#WLElow input").each(function (i, n) {
                            if (i > 3) return;
                            $(this).val(MonitArr[i + 2]);
                        });
                        $("#WLElow").show();
                    } else {
                        WLEID4 = MonitArr[0];
                        $("#caiyanghunhe").html("<span ></span> " + "混合采样:" + MonitArr[0]);
                        if ($("#user3").val() != "privilege") {
                            $("#caiyanghunhe").html("<span ></span> " + "混合采样:" + MonitArr[0] + "&nbsp;&nbsp;&nbsp;<button id=\"updateWLEmix\" style=\"float:right;margin-right:16%;\">修改</button>&nbsp;&nbsp;&nbsp; <button id=\"deleteWLEmix\" class=\"btn-danger\" style=\"float:right;margin-right:13%;\">删除</button>");
                        }
                        $("#WLEmix input").each(function () {
                            $(this).val("4");
                        });
                        $("#WLEmix input").each(function (i, n) {
                            if (i > 3) return;
                            $(this).val(MonitArr[i + 2]);
                        });
                        $("#WLEmix").show();
                    }
                }
                //隐藏断面下面的浮游生物、底栖生物表格
                /*   $(".surface").hide();

                   $("#add-monitsite").css({"display": "none"});
                   $("#add-surface").css({"display": "none"});
                   $("#add-line").css({"display": "none"});
                   $("#add-Dot").css({"display": "block"});
                   $("#add-water").css({"display": "none"});
                   $("#add-child-sub").css({"display": "none"});
                   $("#add-child-node").css({"display": "none"});
   */
            }
        });
    });

//网具
    $('.show-wj').click(function(){
        var shuicengid;
        images=[];
        $("#testTool").validate({}).resetForm();
        $("#wangjubiao input").each(function () {
            $(this).val("");
        });
        $("#wjps").text("未选择文件");
        buttonID = $(this).attr("ID");
        if (buttonID == "caiyangshangbt") {
            shuicengid=$("#caiyangshang").html().substring(20,37);

            //$("#wjid").html("网具编号："+$("#caiyangshang").html().substring(21,39)+" <span class=\"close glyphicon glyphicon-remove\"></span>");
        }
        else if (buttonID == "caiyangzhongbt") {
            shuicengid=$("#caiyangzhong").html().substring(20,37);
        }
        else if (buttonID == "caiyangxiabt") {
            shuicengid=$("#caiyangxia").html().substring(20,37);
        }
        else if (buttonID == "caiyanghunhebt") {
            shuicengid=$("#caiyanghunhe").html().substring(19,36);
        }
        fatherID=shuicengid;
        $.ajax({
            type: "get",
            async: true,
            url: "AllMonit.action?monitID=" + shuicengid,
            success: function (result) {
                if (result == "00") {

                    return;
                } else if (result == "" || result == null) {
                    if(confirm("无网具!是否添加?"))
                    {
                        $("#showTool input").each(function(i,n)
                        {
                            $(this).val("");
                        });
                        $(".title").text("添加网具");
                        $("#testTool").validate({}).resetForm();
                        $("#toolSumbit").text("确认提交");
                        $("#showTool").css({"display": "block"});
                        return;
                    }
                } else {
                    var nodeArray = result.split(",");
                    var catchesCount = 0;
                    /*for (var j = 0; j < nodeArray.length; j++) {
                        var select = tr[j];
                        if (nodeArray[j].substring(0, 3) == "CTH"){
                            catchesCount++;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + nodeArray[j],
                                async: false,
                                success: function (result) {
                                    var Mon0 = result.split(",");
                                    $("#" + select).show();
                                    $("#" + select + " td").each(function (i, n) {
                                        if (i >= 6) return;
                                        if (i == 0 || i == 1) {
                                            $(this).html(Mon0[i]);
                                            return;
                                        }
                                        if (i == 5) {
                                            if (Mon0[2].length == 0) {
                                                catchesImages = [];
                                            } else catchesImages = Mon0[2].split("|");
                                            return;
                                        }
                                        $(this).html(Mon0[i + 1]);
                                    });
                                    $("#" + select + " button").each(function (i, n) {
                                        if (userName == "privilege" && $(this).text() == "添加") {
                                            return;
                                        }
                                        $(this).css({"display": "inline-block"});
                                    });
                                }
                            });
                        }else if(nodeArray[j].substring(0, 3) == "WDD"){
                            var selectID = wd[j - catchesCount];
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + nodeArray[j],
                                async: false,
                                success: function (result) {
                                    var Mon1 = result.split(",");
                                    $("#" + selectID).show();
                                    $("#" + selectID + " td").each(function (i, n) {
                                        if (i > 3) return;
                                        $(this).html(Mon1[i]);
                                    });
                                    $("#" + selectID + " button").each(function (i, n) {
                                        if (userName == "privilege" && $(this).text() == "添加") {
                                            return;
                                        }
                                        $(this).css({"display": "inline-block"});
                                    });
                                }
                            });
                        }else {
                            break;
                        }
                    }
*/
                    var flag=0;
                    for (var j = 0; j < nodeArray.length; j++) {
                        if (nodeArray[j].substring(0, 3) == "NET") {
                            flag=1;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + nodeArray[j],
                                async: true,
                                success: function (result) {
                                    var Mon1 = result.split(",");
                                    $("#addTool").css({"display": "none"});
                                    $("#toolTable").show();
                                    $("#wangjubiao input").each(function (i, n) {

                                        if (i > 8) return;
                                        if (i == 0 || i == 1) {
                                            if(i==0)
                                            {
                                                selectID=Mon1[i];
                                            }
                                            $(this).val(Mon1[i]);
                                            return;
                                        }
                                        if (i == 8) {
                                            var toolImages;
                                            if (Mon1[2].length == 0) {
                                                toolImages = [];
                                            } else {
                                                toolImages = Mon1[2].split("|");
                                                images = toolImages;

                                                $("#imgDiv").css({"display":"inline-block"});
                                                if(toolImages.length==0) images=[];
                                                if(images.length==0) {return;}
                                                console.log(images);
                                                imagelength=images.length;
                                                currnt = 0;
                                                console.log("wj"+images.length);
                                                console.log(str+selectID+"/"+images[0]);
                                                $("#imgw").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                                                $("#imagewj").val(images);
                                            }
                                            return;
                                        }
                                        if (i == 5 || i == 6) {
                                            $(this).val(Mon1[i + 1].substring(0, 8));
                                            return;
                                        }
                                        $(this).val(Mon1[i + 1]);
                                    });
                                }

                            });
                        }
                    }
                    if(flag==0)
                    {
                        if(confirm("无网具!是否添加?"))
                        {
                            $(".title").text("添加网具");
                            $("#toolSumbit").text("确认提交");
                            $("#testTool").validate({}).resetForm();
                            $("#showTool input").each(function(i,n)
                            {
                                $(this).val("");
                            });
                            $("#showTool").css({"display": "block"});
                            return;
                        }
                    }
                    else {
                        $('#sz').hide();
                        $('#yhw').hide();
                        $('#wj').fadeIn();
                        $("#wj").draggable();
                        $('#p-l-c-mask').fadeIn();
                    }
                }
            }
        });
    });
    $('#wj .close').click(function(e){
        $('#p-l-c-mask').hide();
    });
    var wjIndex = 0;
    var currnt = 0;
    $('.wj-pre').click(function(){
        var src;
        if(currnt == 0) currnt = imagelength-1;
        else currnt--;
        $("#imgw").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        $("#imgyyb").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        $("#imgyhw").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        $("#imglyb").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        console.log("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
    });

    $('.wj-next').click(function(){
        if(currnt == imagelength-1) currnt=0;
        else currnt++;
        $("#imgw").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        $("#imgyyb").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        $("#imgyhw").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        $("#imglyb").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
        console.log("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
    });
//水质监测
    $('.show-sz').click(function(){
        var buttonID;
        var shuicengid;
        $("#shuizhibiao input").each(function () {
            $(this).val("");
        });
        buttonID = $(this).attr("ID");
        if (buttonID == "caiyangshangbts") {
            shuicengid=$("#caiyangshang").html().substring(20,37);

            //$("#wjid").html("网具编号："+$("#caiyangshang").html().substring(21,39)+" <span class=\"close glyphicon glyphicon-remove\"></span>");
        }
        else if (buttonID == "caiyangzhongbts") {
            shuicengid=$("#caiyangzhong").html().substring(20,37);
        }
        else if (buttonID == "caiyangxiabts") {
            shuicengid=$("#caiyangxia").html().substring(20,37);
        }
        else if (buttonID == "caiyanghunhebts") {
            shuicengid=$("#caiyanghunhe").html().substring(19,36);
        }
        fatherID=shuicengid;
        $.ajax({
            type: "get",
            async: true,
            url: "AllMonit.action?monitID=" + shuicengid,
            success: function (result) {
                if (result == "00") {

                    return;
                } else if (result == "" || result == null) {
                    if(confirm("无水质监测数据!是否添加?"))
                    {
                        $(".title").text("添加水质监测数据");
                        $("#detectionSubmit").text("确认提交");
                        $("#showDetection").css({"display": "block"});

                        $("#showDetection input").each(function (i, n) {
                            $(this).val("");
                        });
                    }
                } else {
                    var nodeArray = result.split(",");
                    var catchesCount = 0;
                    flagsz=0;
                    for (var j = 0; j < nodeArray.length; j++) {
                        if(nodeArray[j].substring(0, 3) == "WDD"){
                            flagsz++;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + nodeArray[j],
                                async: false,
                                success: function (result) {
                                    var Mon1 = result.split(",");
                                    flagnumssz[flagsz]=Mon1;
                                    if(flagsz==1) {
                                        $("#shuizhibiao input").each(function (i, n) {
                                            if (i > 3) return;
                                            $(this).val(Mon1[i]);
                                        });
                                    }
                                }
                            });
                        }
                    }
                    if(flagsz==0)
                    {
                        if(confirm("无水质监测数据!是否添加?"))
                        {
                            $(".title").text("添加水质监测数据");
                            $("#detectionSubmit").text("确认提交");
                            $("#showDetection input").each(function(i,n)
                            {
                                $(this).val("");
                            });
                            $("#showDetection").css({"display": "block"});

                            $("#showDetection input").each(function (i, n) {
                                $(this).val("");
                            });
                        }
                    }
                    else {
                        pagnumsz=1;
                        $("#shuizhitou").html("第"+pagnumsz+"页/共"+flagsz+"页\n" );
                        $('#wj').hide();
                        $('#yhw').hide();
                        $('#sz').fadeIn();
                        $('#p-l-c-mask').fadeIn();
                    }

                }
            }
        });
    });
    $('#sz .close').click(function(e){
        $("#shuizhijiance").validate({}).resetForm();
        $('#p-l-c-mask').hide();
    });
    var szIndex = 0;
    $('.sz-pre').click(function(){
        var length = $('.wj-img').length;
        if(szIndex>0){
            $('.wj-img:eq('+szIndex+')').hide();
            $('.wj-img:eq('+(szIndex-1)+')').show();
            wjIndex -=1;
        }
    });

    $('.sz-next').click(function(){
        var length = $('.wj-img').length;
        if(szIndex<length-1){
            $('.wj-img:eq('+szIndex+')').hide();
            $('.wj-img:eq('+(szIndex+1)+')').show();
            szIndex +=1;
        }
    });

    $('.sz-next-page').click(function(){
        if(pagnumsz==flagsz)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumssz[pagnumsz+1];
            $("#shuizhijiance").validate({}).resetForm();
            $("#shuizhibiao input").each(function (i, n) {
                if (i > 3) return;
                $(this).val(ar[i]);
            });
            pagnumsz++;
            $("#shuizhitou").html("第"+pagnumsz+"页/共"+flagsz+"页\n" );

        }
    });
    $('.sz-pre-page').click(function(){
        if(pagnumsz==1)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumssz[pagnumsz-1];
            $("#shuizhijiance").validate({}).resetForm();
            $("#shuizhibiao input").each(function (i, n) {
                if (i > 3) return;
                $(this).val(ar[i]);
            });
            pagnumsz--;
            $("#shuizhitou").html("第"+pagnumsz+"页/共"+flagsz+"页\n" );

        }
        validator.resetForm();
    });
//渔获物
    $('.show-yhw').click(function(){
        $("#imgyhw").attr("src","");
        var shuicengid;
        $("#yuhuowubiao input").each(function () {
            $(this).val("");
        });
        $("#yhwps").text("未选择文件");
        buttonID = $(this).attr("ID");
        if (buttonID == "caiyangshangbty") {
            shuicengid=$("#caiyangshang").html().substring(20,37);
            //$("#wjid").html("网具编号："+$("#caiyangshang").html().substring(21,39)+" <span class=\"close glyphicon glyphicon-remove\"></span>");
        }
        else if (buttonID == "caiyangzhongbty") {
            shuicengid=$("#caiyangzhong").html().substring(20,37);
        }
        else if (buttonID == "caiyangxiabty") {
            shuicengid=$("#caiyangxia").html().substring(20,37);
        }
        else if (buttonID == "caiyanghunhebty") {
            shuicengid=$("#caiyanghunhe").html().substring(19,36);
        }
        fatherID=shuicengid;
        $.ajax({
            type: "get",
            async: true,
            url: "AllMonit.action?monitID=" + shuicengid,
            success: function (result) {
                if (result == "00"||result == "" || result == null) {
                    if(confirm("无渔获物!是否添加?")) {
                        $(".title").text("添加渔获物");
                        $("#testGet").validate({}).resetForm();
                        $("#getSumbit").text("确认提交");
                        $("#showGet").css({"display": "block"});
                        $("#showGet input").each(function (i, n) {
                            $(this).val("");
                        });
                    }
                    return;
                } else {
                    var nodeArray = result.split(",");
                    flagyhw=0;
                    var catchesCount = 0;
                    for (var j = 0; j < nodeArray.length; j++) {

                        if (nodeArray[j].substring(0, 3) == "CTH") {

                            flagyhw++;
                            catchesCount++;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + nodeArray[j],
                                async: false,
                                success: function (result) {
                                    var Mon0 = result.split(",");
                                    flagnumsyhw[flagyhw]=Mon0;
                                    if(flagyhw==1) {
                                        $("#yuhuowubiao input").each(function (i, n) {

                                            if (i >= 6) return;
                                            if (i == 0 || i == 1) {
                                                $(this).val(Mon0[i]);
                                                return;
                                            }
                                            if (i == 5) {
                                                if (Mon0[2].length == 0) {
                                                    images = [];
                                                } else images = Mon0[2].split("|");
                                                return;
                                            }
                                            $(this).val(Mon0[i + 1]);
                                        });
                                        var ID  = $("#yuhuowuid").val();
                                        if(ID.length == 0) {
                                            return;
                                        }
                                        $.ajax({
                                            type:"get",
                                            async:true,
                                            url:"op_catch.action",
                                            data:{
                                                "flag":"getAllPhoto",
                                                "NodeName":ID,								//主键

                                            },
                                            success:function(result){
                                                if(result.length==0) images=[];
                                                else images = result.split("|");
                                                console.log(result+"               "+images);
                                                selectID = ID;
                                                if(images.length==0) {return;}
                                                imagelength=images.length;
                                                currnt = 0;
                                                console.log("yhw"+images.length);
                                                console.log(str+selectID+"/"+images[0]);
                                                $("#imageyhw").val(images);
                                                $("#imgyhw").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                                            }
                                        });
                                    }
                                }
                            });
                        }
                    }
                }
                if(flagyhw==0)
                {
                    if(confirm("无渔获物!是否添加?")) {

                        $(".title").text("添加渔获物");
                        $("#testGet").validate({}).resetForm();
                        $("#getSumbit").text("确认提交");
                        $("#showGet").css({"display": "block"});
                        $("#showGet input").each(function (i, n) {
                            $(this).val("");
                        });
                    }
                }
                else {
                    pagnumyhw=1;

                    $("#yuhuowutou").html("第"+pagnumyhw+"页/共"+flagyhw+"页\n" );
                    $('#wj').hide();
                    $('#sz').hide();
                    $('#yhw').fadeIn();
                    $('#p-l-c-mask').fadeIn();
                }
            }
        });

    });
    $('#yhw .close').click(function(e){
        $("#yuhuowu").validate({}).resetForm();
        $('#yhw').hide();
        $('#p-l-c-mask').hide();
    });
    var yhwIndex = 0;
    $('.yhw-pre').click(function(){
        var length = $('.yhw-img').length;
        if(yhwIndex>0){
            $('.yhw-img:eq('+yhwIndex+')').hide();
            $('.yhw-img:eq('+(yhwIndex-1)+')').show();
            yhwIndex -=1;
        }
    });

    $('.yhw-next').click(function(){
        var length = $('.yhw-img').length;
        if(yhwIndex<length-1){
            $('.yhw-img:eq('+yhwIndex+')').hide();
            $('.yhw-img:eq('+(yhwIndex+1)+')').show();
            yhwIndex +=1;
        }
    });

    $('.yhw-next-page').click(function(){
        if(pagnumyhw==flagyhw)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumsyhw[pagnumyhw+1];
            $("#yuhuowu").validate({}).resetForm();
            $("#yuhuowubiao input").each(function (i, n) {
                if (i > 4) return;
                if (i == 0 || i == 1) {
                    $(this).val(ar[i]);
                }
                else{
                    $(this).val(ar[i+1]);
                }
            });
            $("#yhwps").text("未选择文件");
            var ID  = $("#yuhuowuid").val();
            if(ID.length == 0) return;
            $.ajax({
                type:"get",
                async:true,
                url:"op_catch.action",
                data:{
                    "flag":"getAllPhoto",
                    "NodeName":ID,								//主键

                },
                success:function(result){
                    if(result.length==0) images=[];
                    else images = result.split("|");
                    console.log(result+"               "+images);
                    selectID = ID;

                    imagelength=images.length;
                    console.log(images);
                    currnt = 0;
                    console.log("yhw"+images.length);
                    console.log(str+selectID+"/"+images[0]);
                    $("#imgyhw").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                    $("#imageyhw").val(images);
                }
            });
            pagnumyhw++;
            $("#yuhuowutou").html("第"+pagnumyhw+"页/共"+flagyhw+"页\n" );

        }
    });
    $('.yhw-pre-page').click(function(){
        if(pagnumyhw==1)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsyhw[pagnumyhw-1];
            $("#yuhuowu").validate({}).resetForm();
            $("#yuhuowubiao input").each(function (i, n) {
                if (i > 4) return;
                if (i == 0 || i == 1) {
                    $(this).val(ar[i]);
                }
                else{
                    $(this).val(ar[i+1]);
                }
            });
            $("#yhwps").text("未选择文件");
            var ID  = $("#yuhuowuid").val();
            if(ID.length == 0) return;
            $.ajax({
                type:"get",
                async:true,
                url:"op_catch.action",
                data:{
                    "flag":"getAllPhoto",
                    "NodeName":ID,								//主键
                },
                success:function(result){
                    if(result.length==0) images=[];
                    else images = result.split("|");
                    console.log(result+"               "+images);
                    selectID = ID;
                    imagelength=images.length;
                    console.log(images);
                    currnt = 0;
                    console.log("yhw"+images.length);
                    console.log(str+selectID+"/"+images[0]);
                    $("#imgyhw").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                    $("#imageyhw").val(images);
                }
            });
            pagnumyhw--;
            $("#yuhuowutou").html("第"+pagnumyhw+"页/共"+flagyhw+"页\n" );

        }
    });

//鱼样本
    $('.show-yyb').click(function(){
        flagyyb=0;
        var ID = $("#yuhuowuid").val();
        $("#yuyangbenbiao input").each(function (i, n) {
            if (i > 10) return;
            $(this).val("");
        });
        $("#yybps").text("未选择文件");
        $.ajax({
            type: "get",
            async: true,
            url: "AllMonit.action?monitID=" + ID,
            success: function (result) {
                if (result == "00") {

                    return;
                } else if (result.indexOf("FSS") < 0) {
                    alert("没有鱼样本");
                } else {
                    MonitArr = result.split(',');
                    pagnumyyb=1;
                    for (var i = 0; i < MonitArr.length; i++) {
                        if (MonitArr[i].substring(0, 3) == "FSS"){
                            flagyyb++;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + MonitArr[i],
                                async: false,
                                success: function (result) {
                                    var Mon = result.split(",");
                                    flagnumsyyb[flagyyb]=Mon;
                                    if(flagyyb==1) {
                                        console.log("鱼样本            "+Mon);
                                        $("#yuyangbenbiao input").each(function (i, n) {
                                            if (i > 10) return;
                                            $(this).val("");
                                        });
                                        $("#yuyangbenbiao input").each(function (i, n) {
                                            if (i > 10) return;
                                            if (i == 0) {
                                                $(this).val(Mon[i]);
                                                return;
                                            }
                                            else if(i==1){$("#yyb1").val(Mon[i+1]);}
                                            else if(i==2){$("#yyb2").val(Mon[i+1]);}
                                            else if(i==3){$("#yyb3").val(Mon[i+1]);}
                                            else if(i==4){$("#yyb4").val(Mon[i+1]);}
                                            else if(i==5){$("#yyb5").val(Mon[i+2]);}
                                            else if(i==6){$("#yyb6").val(Mon[i+2]);}
                                            else if(i==7){$("#yyb7").val(Mon[i+2]);}
                                            else if(i==8){$("#yyb8").val(Mon[i+2]);}
                                            else if(i==9){$("#yyb9").val(Mon[i+2]);}
                                            else if(i==10){$("#yyb10").val(Mon[i+2]);}
                                        });
                                    }
                                }
                            });
                        }
                    }
                    ID  = $("#yuyangbenid").val();
                    console.log("                  234 "+ID);
                    if(ID.length == 0) return;
                    $.ajax({
                        type:"get",
                        async:true,
                        url:"op_fish.action",
                        data:{
                            "flag":"getAllPhoto",
                            "NodeName":ID,								//主键

                        },
                        success:function(result){
                            if(result.length==0) images=[];
                            else images = result.split("|");
                            console.log(result+"               "+images);
                            selectID = ID;
                            console.log(images);
                            console.log("yyb"+images.length);
                            currnt = 0;
                            imagelength=images.length;
                            console.log(str+selectID+"/"+images[0]);
                            $("#imgyyb").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                            $("#imageyyb").val(images);
                        }
                    });
                    $("#yuwuranbiao input").each(function (i, n) {
                        if (i > 4) return;
                        $(this).val("");
                    });
                    ID=$("#yuyangbenid").val();

                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + ID,
                        success: function (result) {
                            if (result == "00") {
                                return;
                            } else if (result.indexOf("FEP") < 0) {
                                $("#updateFishEP").hide();
                                $("#fishEPDelete").hide();
                                $("#yuwuranbiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#ywrjiantou").hide();
                            } else {
                                $("#ywrjiantou").show();
                                if ($("#user3").val() != "privilege") {
                                    $("#ywrjiantou").show();
                                    $("#updateFishEP").show();
                                    $("#fishEPDelete").show();
                                }
                                $("#yuwuranbiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                flagywr = 0;
                                pagnumywr = 1;
                                MonitArr = result.split(',');
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "FEP") {
                                        flagywr++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsywr[flagywr]=Mon;
                                                if(flagywr==1) {
                                                    $("#yuwuranbiao input").each(function (i, n) {
                                                        if (i > 4) return;
                                                        else $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });
                    ID = $("#yuyangbenid").val();

                    $("#yybfz").val("");
                    $("#fenziyangbenbiao input").each(function (i, n) {
                        if(i==0)
                        {
                            $(this).val("");
                        }
                        else {
                            if (i > 3) return;
                            else $(this).val("");
                        }
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + ID,
                        success: function (result) {
                            if (result == "00") {
                                alert("发生错误，请稍后再试！1");
                                return;
                            } else if (result.indexOf("MMR") < 0) {
                                $("#updateMolecule").hide();
                                $("#moleculeDelete").hide();
                                $("#addPrim").hide();
                                $("#addSample").hide();
                                $("#updatePrim").hide();
                                $("#primDelete").hide();
                                $("#updateSample").hide();
                                $("#sampleDelete").hide();
                                $("#yybfz").attr("disabled","disabled");
                                $("#fenziyangbenbiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#yinwubiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#danyangbenbiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#fzjiantou").hide();
                                $("#ywjiantou").hide();
                                $("#dybjiantou").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $('#yybfz').removeAttr("disabled");
                                    $("#ywjiantou").show();
                                    $("#dybjiantou").show();
                                    $("#fzjiantou").show();
                                    $('#yybfz').removeAttr("disabled");
                                }
                                $("#fenziyangbenbiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                $("#yinwubiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                $("#danyangbenbiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                if ($("#user3").val() != "privilege") {
                                    $("#updateMolecule").show();
                                    $("#moleculeDelete").show();
                                    $("#addPrim").show();
                                    $("#addSample").show();
                                }
                                flagfz=0;
                                pagnumfz=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "MMR") {
                                        flagfz++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsfz[flagfz]=Mon;
                                                if(flagfz==1) {
                                                    ID=Mon[0];
                                                    $("#yybfz").val(Mon[1]);
                                                    $("#fenziyangbenbiao input").each(function (i, n) {
                                                        if(i==0)
                                                        {
                                                            $(this).val(Mon[i]);
                                                        }
                                                        else {
                                                            if (i > 3) return;
                                                            else $(this).val(Mon[i+1]);
                                                        }
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                            ID=$("#fenziyangbenid").val();

                            $("#yinwubiao input").each(function (i, n) {
                                if (i > 3) return;
                                $(this).val("");
                            });
                            $.ajax({
                                type: "get",
                                async: true,
                                url:"AllMonit.action?monitID=MMR" + ID,
                                success: function (result) {
                                    if (result == "00") {
                                        return;
                                    } else if (result.indexOf("PRI") < 0) {
                                        $("#updatePrim").hide();
                                        $("#primDelete").hide();
                                        $("#yinwubiao input").each(function (i, n) {
                                            $(this).attr("readonly","readonly");
                                        });
                                        $("#ywjiantou").hide();
                                    } else {
                                        if ($("#user3").val() != "privilege") {
                                            $("#ywjiantou").show();
                                            $("#updatePrim").show();
                                            $("#primDelete").show();
                                        }
                                        $("#yinwubiao input").each(function (i, n) {
                                            $(this).removeAttr("readonly");
                                        });
                                        MonitArr = result.split(',');
                                        flagyw = 0;
                                        pagnumyw = 1;
                                        for (var i = 0; i < MonitArr.length; i++) {
                                            if(MonitArr[i].substring(0, 3) == "PRI"){
                                                flagyw++;
                                                $.ajax({
                                                    type: "get",
                                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                                    async: false,
                                                    success: function (result) {
                                                        var Mon = result.split(",");
                                                        flagnumsyw[flagyw]=Mon;
                                                        if(flagyw==1) {
                                                            $("#yinwubiao input").each(function (i, n) {
                                                                if (i > 3) return;
                                                                $(this).val(Mon[i]);
                                                            });
                                                        }
                                                    }
                                                });

                                            }
                                        }
                                    }
                                }
                            });

                            ID = $("#fenziyangbenid").val();
                            $("#danyangbenbiao input").each(function (i, n) {
                                if (i > 2) return;
                                $(this).val("");
                            });
                            $.ajax({
                                type: "get",
                                async: true,
                                url: "AllMonit.action?monitID=" + "MMR" + ID,
                                success: function (result) {
                                    if (result == "00") {
                                        return;
                                    } else if (result.indexOf("SIF") < 0) {
                                        $("#updateSample").hide();
                                        $("#sampleDelete").hide();
                                        $("#danyangbenbiao input").each(function (i, n) {
                                            $(this).attr("readonly","readonly");
                                        });
                                        $("#dybjiantou").hide();
                                    } else {
                                        if ($("#user3").val() != "privilege") {
                                            $("#dybjiantou").show();
                                            $("#updateSample").show();
                                            $("#sampleDelete").show();
                                        }
                                        $("#danyangbenbiao input").each(function (i, n) {
                                            $(this).removeAttr("readonly");
                                        });
                                        MonitArr = result.split(',');
                                        flagdyb = 0;
                                        pagnumdyb=1;
                                        for (var i = 0; i < MonitArr.length; i++) {
                                            if (MonitArr[i].substring(0, 3) == "SIF") {
                                                flagdyb++;
                                                $.ajax({
                                                    type: "get",
                                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                                    async: false,
                                                    success: function (result) {
                                                        var Mon = result.split(",");
                                                        flagnumsdyb[flagdyb]=Mon;
                                                        if(flagdyb==1) {
                                                            $("#danyangbenbiao input").each(function (i, n) {
                                                                if (i > 2) return;
                                                                $(this).val(Mon[i]);
                                                            });
                                                        }
                                                    }
                                                });
                                            }
                                        }
                                    }
                                }
                            });
                        }
                    });
                    $("#yuyangbentou").html("第1页/共"+flagyyb+"页\n" );
                    $('#yyb').fadeIn();
                    $('#p-l-c-mask').fadeIn();
                }
            }
        });
    });
    $('#yyb .close').click(function(e){
        $("#yuyangben").validate({}).resetForm();
        $('#yyb').hide();
        $('#yhw').hide();
        $('#p-l-c-mask').hide();
        if (buttonID == "caiyangshangbty") {
            $('#caiyangshangbty').click();
            //$("#wjid").html("网具编号："+$("#caiyangshang").html().substring(21,39)+" <span class=\"close glyphicon glyphicon-remove\"></span>");
        }
        else if (buttonID == "caiyangzhongbty") {
            $('#caiyangzhongbty').click();
        }
        else if (buttonID == "caiyangxiabty") {
            $('#caiyangxiabty').click();
        }
        else if (buttonID == "caiyanghunhebty") {
            $('#caiyanghunhebty').click();
        }
    });

    var yybIndex = 0;
    $('.yyb-pre').click(function(){
        var length = $('.yyb-img').length;
        if(yybIndex>0){
            $('.yyb-img:eq('+yybIndex+')').hide();
            $('.yyb-img:eq('+(yybIndex-1)+')').show();
            yybIndex -=1;
        }
    });

    $('.yyb-next').click(function(){
        var length = $('.yyb-img').length;
        if(yybIndex<length-1){
            $('.yyb-img:eq('+yybIndex+')').hide();
            $('.yyb-img:eq('+(yybIndex+1)+')').show();
            yybIndex +=1;
        }
    });

    $('.yyb-next-page').click(function(){
        if(pagnumyyb==flagyyb)
        {
            alert("已经是最后一页了！");
        }
        else {

            var ar=flagnumsyyb[pagnumyyb+1];
            $("#yuyangben").validate({}).resetForm();
            $("#yuyangbenbiao input").each(function (i, n) {
                if (i > 10) return;
                $(this).val("");
            });
            $("#yuyangbenbiao input").each(function (i, n) {
                if (i > 10) return;
                if (i == 0) {
                    $(this).val(ar[i]);
                    return;
                }
                else if(i==1){$("#yyb1").val(ar[i+1]);}
                else if(i==2){$("#yyb2").val(ar[i+1]);}
                else if(i==3){$("#yyb3").val(ar[i+1]);}
                else if(i==4){$("#yyb4").val(ar[i+1]);}
                else if(i==5){$("#yyb5").val(ar[i+2]);}
                else if(i==6){$("#yyb6").val(ar[i+2]);}
                else if(i==7){$("#yyb7").val(ar[i+2]);}
                else if(i==8){$("#yyb8").val(ar[i+2]);}
                else if(i==9){$("#yyb9").val(ar[i+2]);}
                else if(i==10){$("#yyb10").val(ar[i+2]);}
            });
            pagnumyyb++;
            $("#yybps").text("未选择文件");
            $("#yuyangbentou").html("第"+pagnumyyb+"页/共"+flagyyb+"页\n" );
            for (var j = 0; j < 5; j++) {
                $("#yuwuranbiao input").each(function (i, n) {
                    if (i > 4) return;
                    $(this).val("");
                });
            }
            var ID=$("#yuyangbenid").val();

            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("FEP") < 0) {
                        $("#updateFishEP").hide();
                        $("#fishEPDelete").hide();
                        $("#yuwuranbiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#ywrjiantou").hide();
                    } else {$("#ywrjiantou").show();
                        if ($("#user3").val() != "privilege") {
                            $("#ywrjiantou").show();
                            $("#updateFishEP").show();
                            $("#fishEPDelete").show();
                        }
                        $("#yuwuranbiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        flagywr=0;
                        pagnumywr=1;
                        MonitArr = result.split(',');
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "FEP") {
                                flagywr++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsywr[flagywr]=Mon;
                                        if(flagywr==1) {
                                            $("#yuwuranbiao input").each(function (i, n) {
                                                if (i > 4) return;
                                                else $(this).val(Mon[i]);
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
            });
            ID  = $("#yuyangbenid").val();
            console.log("                  234 "+ID);
            if(ID.length == 0) return;
            $.ajax({
                type:"get",
                async:true,
                url:"op_fish.action",
                data:{
                    "flag":"getAllPhoto",
                    "NodeName":ID,								//主键

                },
                success:function(result){
                    if(result.length==0) images=[];
                    else images = result.split("|");
                    console.log(result+"               "+images);
                    selectID = ID;
                    console.log(images);
                    console.log("yyb"+images.length);
                    currnt = 0;
                    imagelength=images.length;
                    console.log(str+selectID+"/"+images[0]);
                    $("#imgyyb").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                    $("#imageyyb").val(images);
                }
            });
            ID = $("#yuyangbenid").val();

            $("#yybfz").val("");
            $("#fenziyangbenbiao input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val("");
                }
                else {
                    if (i > 3) return;
                    else $(this).val("");
                }
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + ID,
                success: function (result) {
                    if (result == "00") {
                        alert("发生错误，请稍后再试！1");
                        return;
                    } else if (result.indexOf("MMR") < 0) {
                        $("#updateMolecule").hide();
                        $("#moleculeDelete").hide();
                        $("#addPrim").hide();
                        $("#addSample").hide();
                        $("#updatePrim").hide();
                        $("#primDelete").hide();
                        $("#updateSample").hide();
                        $("#sampleDelete").hide();
                        $("#yybfz").attr("disabled","disabled");
                        $("#fenziyangbenbiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#yinwubiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#danyangbenbiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#ywrjiantou").hide();
                        $("#fzjiantou").hide();
                        $("#ywjiantou").hide();
                        $("#dybjiantou").hide();
                        
                    } else {
                        $("#ywrjiantou").show();
                        if ($("#user3").val() != "privilege") {
                            $("#ywrjiantou").show();
                            $("#ywjiantou").show();
                            $("#dybjiantou").show();
                            $("#fzjiantou").show();
                                    $('#yybfz').removeAttr("disabled");
                            $("#updateMolecule").show();
                            $("#moleculeDelete").show();
                            $("#addPrim").show();
                            $("#addSample").show();
                        }
                        $("#fenziyangbenbiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#yinwubiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#danyangbenbiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        MonitArr = result.split(',');
                        flagfz=0;
                        pagnumfz=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "MMR") {
                                flagfz++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsfz[flagfz]=Mon;
                                        if(flagfz==1) {
                                            ID=Mon[0];
                                            $("#yybfz").val(Mon[1]);
                                            $("#fenziyangbenbiao input").each(function (i, n) {
                                                if(i==0)
                                                {
                                                    $(this).val(Mon[i]);
                                                }
                                                else {
                                                    if (i > 3) return;
                                                    else $(this).val(Mon[i+1]);
                                                }
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                    ID=$("#fenziyangbenid").val();

                    $("#yinwubiao input").each(function (i, n) {
                        if (i > 3) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url:"AllMonit.action?monitID=MMR" + ID,
                        success: function (result) {
                            if (result == "00") {

                                return;
                            } else if (result.indexOf("PRI") < 0) {
                                $("#updatePrim").hide();
                                $("#primDelete").hide();
                                $("#yinwubiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#ywjiantou").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#ywjiantou").show();
                                    $("#updatePrim").show();
                                    $("#primDelete").show();
                                }
                                $("#yinwubiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagyw=0;
                                pagnumyw=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if(MonitArr[i].substring(0, 3) == "PRI"){
                                        flagyw++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsyw[flagyw]=Mon;
                                                if(flagyw==1) {
                                                    $("#yinwubiao input").each(function (i, n) {
                                                        if (i > 3) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });

                                    }
                                }
                            }
                        }
                    });

                    ID = $("#fenziyangbenid").val();
                    $("#danyangbenbiao input").each(function (i, n) {
                        if (i > 2) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + "MMR" + ID,
                        success: function (result) {
                            if (result == "00") {

                                return;
                            } else if (result.indexOf("SIF") < 0) {
                                $("#updateSample").hide();
                                $("#sampleDelete").hide();
                                $("#danyangbenbiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#dybjiantou").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#dybjiantou").show();
                                    $("#updateSample").show();
                                    $("#sampleDelete").show();
                                }
                                $("#danyangbenbiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagdyb=0;
                                pagnumdyb=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "SIF") {
                                        flagdyb++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsdyb[flagdyb]=Mon;
                                                if(flagdyb==1) {
                                                    $("#danyangbenbiao input").each(function (i, n) {
                                                        if (i > 2) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });
                }
            });
        }
    });
    $('.yyb-pre-page').click(function(){
        if(pagnumyyb==1||pagnumyyb==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsyyb[pagnumyyb-1];
            $("#yuyangben").validate({}).resetForm();
            $("#yuyangbenbiao input").each(function (i, n) {
                if (i > 10) return;
                $(this).val("");
            });
            $("#yuyangbenbiao input").each(function (i, n) {
                if (i > 10) return;
                if (i == 0) {
                    $(this).val(ar[i]);
                    return;
                }
                else if(i==1){$("#yyb1").val(ar[i+1]);}
                else if(i==2){$("#yyb2").val(ar[i+1]);}
                else if(i==3){$("#yyb3").val(ar[i+1]);}
                else if(i==4){$("#yyb4").val(ar[i+1]);}
                else if(i==5){$("#yyb5").val(ar[i+2]);}
                else if(i==6){$("#yyb6").val(ar[i+2]);}
                else if(i==7){$("#yyb7").val(ar[i+2]);}
                else if(i==8){$("#yyb8").val(ar[i+2]);}
                else if(i==9){$("#yyb9").val(ar[i+2]);}
                else if(i==10){$("#yyb10").val(ar[i+2]);}
            });
            pagnumyyb--;
            $("#yybps").text("未选择文件");
            $("#yuyangbentou").html("第"+pagnumyyb+"页/共"+flagyyb+"页\n" );
            $("#yuwuranbiao input").each(function (i, n) {
                if (i > 4) return;
                $(this).val("");
            });
            var ID=$("#yuyangbenid").val();

            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("FEP") < 0) {
                        $("#updateFishEP").hide();
                        $("#fishEPDelete").hide();
                        $("#yuwuranbiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#ywrjiantou").hide();;
                    } else {
                        $("#ywrjiantou").show();
                        if ($("#user3").val() != "privilege") {
                            $("#ywrjiantou").show();
                            $("#updateFishEP").show();
                            $("#fishEPDelete").show();
                        }
                        $("#yuwuranbiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        flagywr=0;
                        pagnumywr=1;
                        MonitArr = result.split(',');
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "FEP") {
                                flagywr++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsywr[flagywr]=Mon;
                                        if(flagywr==1) {
                                            $("#yuwuranbiao input").each(function (i, n) {
                                                if (i > 4) return;
                                                else $(this).val(Mon[i]);
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
            });
            ID  = $("#yuyangbenid").val();
            console.log("                  234 "+ID);
            if(ID.length == 0) return;
            $.ajax({
                type:"get",
                async:true,
                url:"op_fish.action",
                data:{
                    "flag":"getAllPhoto",
                    "NodeName":ID,								//主键

                },
                success:function(result){
                    if(result.length==0) images=[];
                    else images = result.split("|");
                    console.log(result+"               "+images);
                    selectID = ID;
                    console.log(images);
                    console.log("yyb"+images.length);
                    currnt = 0;
                    imagelength=images.length;
                    console.log(str+selectID+"/"+images[0]);
                    $("#imgyyb").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                    $("#imageyyb").val(images);
                }
            });
            ID = $("#yuyangbenid").val();

            $("#yybfz").val("");
            $("#fenziyangbenbiao input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val("");
                }
                else {
                    if (i > 3) return;
                    else $(this).val("");
                }
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + ID,
                success: function (result) {
                    if (result == "00") {
                        alert("发生错误，请稍后再试！1");
                        return;
                    } else if (result.indexOf("MMR") < 0) {

                        $("#updateMolecule").hide();
                        $("#moleculeDelete").hide();
                        $("#addPrim").hide();
                        $("#addSample").hide();
                        $("#updatePrim").hide();
                        $("#primDelete").hide();
                        $("#updateSample").hide();
                        $("#sampleDelete").hide();
                        $("#yybfz").attr("disabled","disabled");
                        $("#fenziyangbenbiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#yinwubiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#danyangbenbiao input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#fzjiantou").hide();
                        $("#ywjiantou").hide();
                        $("#dybjiantou").hide();
                    } else {
                        if ($("#user3").val() != "privilege") {
                            $("#ywjiantou").show();
                            $("#dybjiantou").show();
                            $("#fzjiantou").show();
                                    $('#yybfz').removeAttr("disabled");
                            $("#updateMolecule").show();
                            $("#moleculeDelete").show();
                            $("#addPrim").show();
                            $("#addSample").show();
                        }
                        $("#fenziyangbenbiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#yinwubiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#danyangbenbiao input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        MonitArr = result.split(',');
                        flagfz=0;
                        pagnumfz=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "MMR") {
                                flagfz++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsfz[flagfz]=Mon;
                                        if(flagfz==1) {
                                            ID=Mon[0];
                                            $("#yybfz").val(Mon[1]);
                                            $("#fenziyangbenbiao input").each(function (i, n) {
                                                if(i==0)
                                                {
                                                    $(this).val(Mon[i]);
                                                }
                                                else {
                                                    if (i > 3) return;
                                                    else $(this).val(Mon[i+1]);
                                                }
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                    ID=$("#fenziyangbenid").val();

                    $("#yinwubiao input").each(function (i, n) {
                        if (i > 3) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url:"AllMonit.action?monitID=MMR" + ID,
                        success: function (result) {
                            if (result == "00") {

                                return;
                            } else if (result.indexOf("PRI") < 0) {

                                $("#updatePrim").hide();
                                $("#primDelete").hide();
                                $("#yinwubiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#ywjiantou").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#ywjiantou").show();
                                    $("#updatePrim").show();
                                    $("#primDelete").show();
                                }
                                $("#yinwubiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagyw=0;
                                pagnumyw=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if(MonitArr[i].substring(0, 3) == "PRI"){
                                        flagyw++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsyw[flagyw]=Mon;
                                                if(flagyw==1) {
                                                    $("#yinwubiao input").each(function (i, n) {
                                                        if (i > 3) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });

                                    }
                                }
                            }
                        }
                    });

                    ID = $("#fenziyangbenid").val();
                    $("#danyangbenbiao input").each(function (i, n) {
                        if (i > 2) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + "MMR" + ID,
                        success: function (result) {
                            if (result == "00") {

                                return;
                            } else if (result.indexOf("SIF") < 0) {
                                $("#updateSample").hide();
                                $("#sampleDelete").hide();
                                $("#danyangbenbiao input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#dybjiantou").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#dybjiantou").show();
                                    $("#updateSample").show();
                                    $("#sampleDelete").show();
                                }
                                $("#danyangbenbiao input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagdyb=0;
                                pagnumdyb=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "SIF") {
                                        flagdyb++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsdyb[flagdyb]=Mon;
                                                if(flagdyb==1) {
                                                    $("#danyangbenbiao input").each(function (i, n) {
                                                        if (i > 2) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });
                }
            });
        }
    });

    $('.ywr-next-page').click(function(){
        if(pagnumywr==flagywr)
        {
            alert("已经是最后一页了！");
        }
        else {

            var ar=flagnumsywr[pagnumywr+1];
            $("#yuwuranbiao input").each(function (i, n) {
                if (i > 4) return;
                else $(this).val(ar[i]);
            });
            pagnumywr++;
        }
    });
    $('.ywr-pre-page').click(function(){
        if(pagnumywr==1||pagnumywr==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsywr[pagnumywr-1];

            $("#yuwuranbiao input").each(function (i, n) {
                if (i > 4) return;
                else $(this).val(ar[i]);
            });
            pagnumywr--;
        }
    });

    $('.dyb-next-page').click(function(){
        if(pagnumdyb==flagdyb)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumsdyb[pagnumdyb+1];
            $("#danyangbenbiao input").each(function (i, n) {
                if (i > 2) return;
                $(this).val(ar[i]);
            });
            pagnumdyb++;
        }
    });
    $('.dyb-pre-page').click(function(){
        if(pagnumdyb==1||pagnumdyb==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsdyb[pagnumdyb-1];

            $("#danyangbenbiao input").each(function (i, n) {
                if (i > 2) return;
                else $(this).val(ar[i]);
            });
            pagnumdyb--;
        }
    });

    $('.yw-next-page').click(function(){
        if(pagnumyw==flagyw)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumsyw[pagnumyw+1];
            $("#yinwubiao input").each(function (i, n) {
                if (i > 3) return;
                $(this).val(ar[i]);
            });
            pagnumyw++;
        }
    });
    $('.yw-pre-page').click(function(){
        if(pagnumyw==1||pagnumyw==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsyw[pagnumyw-1];

            $("#yinwubiao input").each(function (i, n) {
                if (i > 3) return;
                else $(this).val(ar[i]);
            });
            pagnumyw--;
        }
    });

    $('.fz-next-page').click(function(){
        if(pagnumfz==flagfz)
        {
            alert("已经是最后一页了！");
        }
        else {

            var ar=flagnumsfz[pagnumfz+1];
            $("#yybfz").val(ar[1]);
            $("#fenziyangbenbiao input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val(ar[i]);
                }
                else {
                    if (i > 3) return;
                    else $(this).val(ar[i+1]);
                }
            });
            pagnumfz++;
            var ID=$("#fenziyangbenid").val();

            $("#yinwubiao input").each(function (i, n) {
                if (i > 3) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url:"AllMonit.action?monitID=MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("PRI") < 0) {

                    } else {
                        MonitArr = result.split(',');
                        flagyw=0;
                        pagnumyw=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if(MonitArr[i].substring(0, 3) == "PRI"){
                                flagyw++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsyw[flagyw]=Mon;
                                        if(flagyw==1) {
                                            $("#yinwubiao input").each(function (i, n) {
                                                if (i > 3) return;
                                                $(this).val(Mon[i]);
                                            });
                                        }
                                    }
                                });

                            }
                        }
                    }
                }
            });
            ID = $("#fenziyangbenid").val();
            $("#danyangbenbiao input").each(function (i, n) {
                if (i > 2) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + "MMR" + ID,
                success: function (result) {
                    if (result == "00") {
                        return;
                    } else if (result.indexOf("SIF") < 0) {
                    } else {
                        MonitArr = result.split(',');
                        flagdyb=0;
                        pagnumdyb=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "SIF") {
                                flagdyb++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsdyb[flagdyb]=Mon;
                                        $("#danyangbenbiao input").each(function (i, n) {
                                            if (i > 2) return;
                                            $(this).val(Mon[i]);
                                        });
                                    }
                                });
                            }
                        }
                    }
                }
            });
        }
    });
    $('.fz-pre-page').click(function(){
        if(pagnumfz==1||pagnumfz==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsfz[pagnumfz-1];

            $("#yybfz").val(ar[1]);
            $("#fenziyangbenbiao input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val(ar[i]);
                }
                else {
                    if (i > 3) return;
                    else $(this).val(ar[i+1]);
                }
            });
            pagnumfz--;
            var ID=$("#fenziyangbenid").val();

            $("#yinwubiao input").each(function (i, n) {
                if (i > 3) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url:"AllMonit.action?monitID=MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("PRI") < 0) {

                    } else {
                        MonitArr = result.split(',');
                        flagyw=0;
                        pagnumyw=1;
                        flagnumsyw={};
                        for (var i = 0; i < MonitArr.length; i++) {
                            if(MonitArr[i].substring(0, 3) == "PRI"){
                                flagyw++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsyw[flagyw]=Mon;
                                        if(flagyw==1) {
                                            $("#yinwubiao input").each(function (i, n) {
                                                if (i > 3) return;
                                                $(this).val(Mon[i]);
                                            });
                                        }
                                    }
                                });

                            }
                        }
                    }
                }
            });
            ID = $("#fenziyangbenid").val();
            $("#danyangbenbiao input").each(function (i, n) {
                if (i > 2) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + "MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("SIF") < 0) {
                    } else {
                        MonitArr = result.split(',');
                        flagdyb=0;
                        pagnumdyb=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "SIF") {
                                flagdyb++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsdyb[flagdyb]=Mon;
                                        $("#danyangbenbiao input").each(function (i, n) {
                                            if (i > 2) return;
                                            $(this).val(Mon[i]);
                                        });
                                    }
                                });
                            }
                        }
                    }
                }
            });
        }
    });

//卵样本
    $('.show-lyb').click(function(){
        flaglyb=0;
        var ID = $("#yuhuowuid").val();
        $("#luanyangbenbiao input").each(function (i, n) {
            if (i > 5) return;
            $(this).val("");
        });
        $("#lybps").text("未选择文件");
        $.ajax({
            type: "get",
            async: true,
            url: "AllMonit.action?monitID=" + ID,
            success: function (result) {
                if (result == "00") {

                    return;
                } else if (result.indexOf("FSE") < 0) {
                    alert("没有卵样本");
                } else {
                    MonitArr = result.split(',');
                    flaglyb=0;
                    pagnumlyb=1;
                    for (var i = 0; i < MonitArr.length; i++) {
                        if (MonitArr[i].substring(0, 3) == "FSE"){
                            flaglyb++;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + MonitArr[i],
                                async: false,
                                success: function (result) {
                                    var Mon = result.split(",");
                                    flagnumslyb[flaglyb]=Mon;
                                    if(flaglyb==1) {
                                        $("#luanyangbenbiao input").each(function (i, n) {
                                            if (i > 5) return;
                                            if (i == 0) {
                                                $(this).val(Mon[i]);
                                                return;
                                            }
                                            else $(this).val(Mon[i + 1]);
                                        });
                                    }
                                }
                            });
                        }
                    }
                    ID  = $("#luanyangbenid").val();
                    console.log("                  234 "+ID);
                    $.ajax({
                        type:"get",
                        async:true,
                        url:"op_fish.action",
                        data:{
                            "flag":"getAllPhoto",
                            "NodeName":ID,								//主键

                        },
                        success:function(result){
                            if(result.length==0) images=[];
                            else images = result.split("|");
                            console.log(result+"               "+images);
                            selectID = ID;
                            console.log(images);
                            console.log("lyb"+images.length);
                            currnt = 0;
                            imagelength=images.length;
                            console.log(str+selectID+"/"+images[0]);
                            $("#imglyb").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                            $("#imagelyb").val(images);
                        }
                    });
                    ID = $("#luanyangbenid").val();

                    $("#lybfz").val("");
                    $("#fenziyangbenbiao1 input").each(function (i, n) {
                        if(i==0)
                        {
                            $(this).val("");
                        }
                        else {
                            if (i > 3) return;
                            else $(this).val("");
                        }
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + ID,
                        success: function (result) {
                            if (result == "00") {
                                return;
                            } else if (result.indexOf("MMR") < 0) {
                                $("#updateMolecule1").hide();
                                $("#moleculeDelete1").hide();
                                $("#addPrim1").hide();
                                $("#addSample1").hide();
                                $("#updatePrim1").hide();
                                $("#primDelete1").hide();
                                $("#updateSample1").hide();
                                $("#sampleDelete1").hide();
                                $("#lybfz").attr("disabled","disabled");
                                $("#fenziyangbenbiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#yinwubiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#danyangbenbiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#fzjiantou1").hide();
                                $("#ywjiantou1").hide();
                                $("#dybjiantou1").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#ywjiantou1").show();
                                    $("#dybjiantou1").show();
                                    $("#fzjiantou1").show();
                                    $('#lybfz').removeAttr("disabled");
                                    $("#updateMolecule1").show();
                                    $("#moleculeDelete1").show();
                                    $("#addPrim1").show();
                                    $("#addSample1").show();
                                }
                                $("#fenziyangbenbiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                $("#yinwubiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                $("#danyangbenbiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');

                                flagfz1=0;
                                pagnumfz1=1;
                                flagnumsfz1={};
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "MMR") {
                                        flagfz1++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsfz1[flagfz1]=Mon;
                                                if(flagfz1==1) {
                                                    ID=Mon[0];
                                                    $("#lybfz").val(Mon[1]);
                                                    $("#fenziyangbenbiao1 input").each(function (i, n) {
                                                        if(i==0)
                                                        {
                                                            $(this).val(Mon[i]);
                                                        }
                                                        else {
                                                            if (i > 3) return;
                                                            else $(this).val(Mon[i+1]);
                                                        }
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                            ID=$("#fenziyangbenid1").val();

                            $("#yinwubiao1 input").each(function (i, n) {
                                if (i > 3) return;
                                $(this).val("");
                            });

                            $.ajax({
                                type: "get",
                                async: true,
                                url:"AllMonit.action?monitID=MMR" + ID,
                                success: function (result) {
                                    if (result == "00") {
                                        return;
                                    } else if (result.indexOf("PRI") < 0) {
                                        $("#updatePrim1").hide();
                                        $("#primDelete1").hide();
                                        $("#yinwubiao1 input").each(function (i, n) {
                                            $(this).attr("readonly","readonly");
                                        });
                                        $("#ywjiantou1").hide();
                                    } else {
                                        if ($("#user3").val() != "privilege") {
                                            $("#ywjiantou1").show();
                                            $("#updatePrim1").show();
                                            $("#primDelete1").show();
                                        }
                                        $("#yinwubiao1 input").each(function (i, n) {
                                            $(this).removeAttr("readonly");
                                        });
                                        MonitArr = result.split(',');
                                        flagyw1=0;
                                        pagnumyw1=1;
                                        flagnumsyw1={};
                                        for (var i = 0; i < MonitArr.length; i++) {
                                            if(MonitArr[i].substring(0, 3) == "PRI"){
                                                flagyw1++;
                                                $.ajax({
                                                    type: "get",
                                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                                    async: false,
                                                    success: function (result) {
                                                        var Mon = result.split(",");
                                                        flagnumsyw1[flagyw1]=Mon;
                                                        if(flagyw1==1) {
                                                            $("#yinwubiao1 input").each(function (i, n) {
                                                                if (i > 3) return;
                                                                $(this).val(Mon[i]);
                                                            });
                                                        }
                                                    }
                                                });

                                            }
                                        }
                                    }
                                }
                            });

                            ID = $("#fenziyangbenid1").val();
                            $("#danyangbenbiao1 input").each(function (i, n) {
                                if (i > 2) return;
                                $(this).val("");
                            });
                            $.ajax({
                                type: "get",
                                async: true,
                                url: "AllMonit.action?monitID=" + "MMR" + ID,
                                success: function (result) {
                                    if (result == "00") {
                                        return;
                                    } else if (result.indexOf("SIF") < 0) {
                                        $("#updateSample1").hide();
                                        $("#sampleDelete1").hide();
                                        $("#danyangbenbiao1 input").each(function (i, n) {
                                            $(this).attr("readonly","readonly");
                                        });
                                        $("#dybjiantou1").hide();
                                    } else {
                                        if ($("#user3").val() != "privilege") {
                                            $("#dybjiantou1").show();
                                            $("#updateSample1").show();
                                            $("#sampleDelete1").show();
                                        }
                                        $("#danyangbenbiao1 input").each(function (i, n) {
                                            $(this).removeAttr("readonly");
                                        });
                                        MonitArr = result.split(',');
                                        flagdyb1=0;
                                        pagnumdyb1=1;
                                        flagnumsdyb1={};
                                        for (var i = 0; i < MonitArr.length; i++) {
                                            if (MonitArr[i].substring(0, 3) == "SIF") {
                                                flagdyb1++;
                                                $.ajax({
                                                    type: "get",
                                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                                    async: false,
                                                    success: function (result) {
                                                        var Mon = result.split(",");
                                                        flagnumsdyb1[flagdyb1]=Mon;
                                                        if(flagdyb1==1) {
                                                            $("#danyangbenbiao1 input").each(function (i, n) {
                                                                if (i > 2) return;
                                                                $(this).val(Mon[i]);
                                                            });
                                                        }
                                                    }
                                                });
                                            }
                                        }
                                    }
                                }
                            });
                        }
                    });
                    $("#luanyangbentou").html("第1页/共"+flaglyb+"页\n" );
                    $('#lyb').fadeIn();
                    $('#p-l-c-mask').fadeIn();
                }
            }
        });
    });
    $('#lyb .close').click(function(e){
        $("#luanyangben").validate({}).resetForm();
        $('#lyb').hide();
        $('#yhw').hide();
        $('#p-l-c-mask').hide();
        if (buttonID == "caiyangshangbty") {
            $('#caiyangshangbty').click();
            //$("#wjid").html("网具编号："+$("#caiyangshang").html().substring(21,39)+" <span class=\"close glyphicon glyphicon-remove\"></span>");
        }
        else if (buttonID == "caiyangzhongbty") {
            $('#caiyangzhongbty').click();
        }
        else if (buttonID == "caiyangxiabty") {
            $('#caiyangxiabty').click();
        }
        else if (buttonID == "caiyanghunhebty") {
            $('#caiyanghunhebty').click();
        }
    });

    var lybIndex = 0;
    $('.lyb-pre').click(function(){
        var length = $('.lyb-img').length;
        if(lybIndex>0){
            $('.lyb-img:eq('+lybIndex+')').hide();
            $('.lyb-img:eq('+(lybIndex-1)+')').show();
            lybIndex -=1;
        }
    });

    $('.lyb-next').click(function(){
        var length = $('.lyb-img').length;
        if(lybIndex<length-1){
            $('.lyb-img:eq('+lybIndex+')').hide();
            $('.lyb-img:eq('+(lybIndex+1)+')').show();
            lybIndex +=1;
        }
    });

    $('.lyb-next-page').click(function(){
        if(pagnumlyb==flaglyb)
        {
            alert("已经是最后一页了！");
        }
        else {

            var ar=flagnumslyb[pagnumlyb+1];
            $("#luanyangben").validate({}).resetForm();
            $("#luanyangbenbiao input").each(function (i, n) {
                if (i > 5) return;
                if (i == 0) {
                    $(this).val(ar[i]);
                    return;
                }
                else $(this).val(ar[i + 1]);
            });
            $("#lybps").text("未选择文件");
            pagnumlyb++;
            $("#luanyangbentou").html("第"+pagnumlyb+"页/共"+flaglyb+"页\n" );

            var ID = $("#luanyangbenid").val();

            $("#lybfz").val("");
            $("#fenziyangbenbiao1 input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val("");
                }
                else {
                    if (i > 3) return;
                    else $(this).val("");
                }
            });

            ID  = $("#luanyangbenid").val();
            console.log("                  234 "+ID);
            $.ajax({
                type:"get",
                async:true,
                url:"op_fish.action",
                data:{
                    "flag":"getAllPhoto",
                    "NodeName":ID,								//主键

                },
                success:function(result){
                    if(result.length==0) images=[];
                    else images = result.split("|");
                    console.log(result+"               "+images);
                    selectID = ID;
                    console.log(images);
                    console.log("yyb"+images.length);
                    currnt = 0;
                    imagelength=images.length;
                    console.log(str+selectID+"/"+images[0]);
                    $("#imglyb").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                    $("#imagelyb").val(images);
                }
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + ID,
                success: function (result) {
                    if (result == "00") {
                        return;
                    } else if (result.indexOf("MMR") < 0) {

                        $("#updateMolecule1").hide();
                        $("#moleculeDelete1").hide();
                        $("#addPrim1").hide();
                        $("#addSample1").hide();
                        $("#updatePrim1").hide();
                        $("#primDelete1").hide();
                        $("#updateSample1").hide();
                        $("#sampleDelete1").hide();
                        $("#lybfz").attr("disabled","disabled");
                        $("#fenziyangbenbiao1 input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#yinwubiao1 input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#danyangbenbiao1 input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#fzjiantou1").hide();
                        $("#ywjiantou1").hide();
                        $("#dybjiantou1").hide();
                    } else {
                        if ($("#user3").val() != "privilege") {
                            $("#ywjiantou1").show();
                            $("#dybjiantou1").show();
                            $("#fzjiantou1").show();
                                    $('#lybfz').removeAttr("disabled");
                            $("#updateMolecule1").show();
                            $("#moleculeDelete1").show();
                            $("#addPrim1").show();
                            $("#addSample1").show();
                        }
                        $("#fenziyangbenbiao1 input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#yinwubiao1 input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#danyangbenbiao1 input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        MonitArr = result.split(',');
                        flagfz1=0;
                        pagnumfz1=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "MMR") {
                                flagfz1++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsfz1[flagfz1]=Mon;
                                        if(flagfz1==1) {
                                            ID=Mon[0];
                                            $("#lybfz").val(Mon[1]);
                                            $("#fenziyangbenbiao1 input").each(function (i, n) {
                                                if(i==0)
                                                {
                                                    $(this).val(Mon[i]);
                                                }
                                                else {
                                                    if (i > 3) return;
                                                    else $(this).val(Mon[i+1]);
                                                }
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                    ID=$("#fenziyangbenid1").val();

                    $("#yinwubiao1 input").each(function (i, n) {
                        if (i > 3) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url:"AllMonit.action?monitID=MMR" + ID,
                        success: function (result) {
                            if (result == "00") {

                                return;
                            } else if (result.indexOf("PRI") < 0) {

                                $("#updatePrim1").hide();
                                $("#primDelete1").hide();
                                $("#yinwubiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#ywjiantou1").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#ywjiantou1").show();
                                    $("#updatePrim1").show();
                                    $("#primDelete1").show();
                                }
                                $("#yinwubiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagyw1=0;
                                pagnumyw1=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if(MonitArr[i].substring(0, 3) == "PRI"){
                                        flagyw1++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsyw1[flagyw1]=Mon;
                                                if(flagyw1==1) {
                                                    $("#yinwubiao1 input").each(function (i, n) {
                                                        if (i > 3) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });

                                    }
                                }
                            }
                        }
                    });

                    ID = $("#fenziyangbenid1").val();
                    $("#danyangbenbiao1 input").each(function (i, n) {
                        if (i > 2) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + "MMR" + ID,
                        success: function (result) {
                            if (result == "00") {
                                return;
                            } else if (result.indexOf("SIF") < 0) {
                                $("#updateSample1").hide();
                                $("#sampleDelete1").hide();
                                $("#danyangbenbiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#dybjiantou1").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#dybjiantou1").show();
                                    $("#updateSample1").show();
                                    $("#sampleDelete1").show();
                                }
                                $("#danyangbenbiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagdyb1=0;
                                pagnumdyb1=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "SIF") {
                                        flagdyb1++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsdyb1[flagdyb1]=Mon;
                                                if(flagdyb1==1) {
                                                    $("#danyangbenbiao1 input").each(function (i, n) {
                                                        if (i > 2) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });
                }
            });
        }
    });
    $('.lyb-pre-page').click(function(){
        if(pagnumlyb==1||pagnumlyb==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumslyb[pagnumlyb-1];
            $("#luanyangben").validate({}).resetForm();
            $("#luanyangbenbiao input").each(function (i, n) {
                if (i > 5) return;
                if (i == 0) {
                    $(this).val(ar[i]);
                    return;
                }
                else $(this).val(ar[i + 1]);
            });
            $("#lybps").text("未选择文件");
            pagnumlyb--;
            $("#luanyangbentou").html("第"+pagnumlyb+"页/共"+flaglyb+"页\n" );


            var ID = $("#luanyangbenid").val();

            $("#lybfz").val("");
            $("#fenziyangbenbiao1 input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val("");
                }
                else {
                    if (i > 3) return;
                    else $(this).val("");
                }
            });

            ID  = $("#luanyangbenid").val();
            console.log("                  234 "+ID);
            $.ajax({
                type:"get",
                async:true,
                url:"op_fish.action",
                data:{
                    "flag":"getAllPhoto",
                    "NodeName":ID,								//主键

                },
                success:function(result){
                    if(result.length==0) images=[];
                    else images = result.split("|");
                    console.log(result+"               "+images);
                    selectID = ID;
                    console.log(images);
                    console.log("yyb"+images.length);
                    currnt = 0;
                    imagelength=images.length;
                    console.log(str+selectID+"/"+images[0]);
                    $("#imglyb").attr("src",str+selectID+"/"+images[0]+"?t=" + Math.random());
                    $("#imagelyb").val(images);
                }
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + ID,
                success: function (result) {
                    if (result == "00") {
                        return;
                    } else if (result.indexOf("MMR") < 0) {
                        $("#updateMolecule1").hide();
                        $("#moleculeDelete1").hide();
                        $("#addPrim1").hide();
                        $("#addSample1").hide();
                        $("#updatePrim1").hide();
                        $("#primDelete1").hide();
                        $("#updateSample1").hide();
                        $("#sampleDelete1").hide();
                        $("#lybfz").attr("disabled","disabled");
                        $("#fenziyangbenbiao1 input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#yinwubiao1 input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#danyangbenbiao1 input").each(function (i, n) {
                            $(this).attr("readonly","readonly");
                        });
                        $("#fzjiantou1").hide();
                        $("#ywjiantou1").hide();
                        $("#dybjiantou1").hide();
                    } else {
                        if ($("#user3").val() != "privilege") {
                            $("#ywjiantou1").show();
                            $("#dybjiantou1").show();
                            $("#fzjiantou1").show();
                                    $('#lybfz').removeAttr("disabled");
                            $("#updateMolecule1").show();
                            $("#moleculeDelete1").show();
                            $("#addPrim1").show();
                            $("#addSample1").show();
                        }
                        $("#fenziyangbenbiao1 input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#yinwubiao1 input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        $("#danyangbenbiao1 input").each(function (i, n) {
                            $(this).removeAttr("readonly");
                        });
                        MonitArr = result.split(',');
                        flagfz1=0;
                        pagnumfz1=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "MMR") {
                                flagfz1++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsfz1[flagfz1]=Mon;
                                        if(flagfz1==1) {
                                            ID=Mon[0];
                                            $("#lybfz").val(Mon[1]);
                                            $("#fenziyangbenbiao1 input").each(function (i, n) {
                                                if(i==0)
                                                {
                                                    $(this).val(Mon[i]);
                                                }
                                                else {
                                                    if (i > 3) return;
                                                    else $(this).val(Mon[i+1]);
                                                }
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                    ID=$("#fenziyangbenid1").val();

                    $("#yinwubiao1 input").each(function (i, n) {
                        if (i > 3) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url:"AllMonit.action?monitID=MMR" + ID,
                        success: function (result) {
                            if (result == "00") {

                                return;
                            } else if (result.indexOf("PRI") < 0) {
                                $("#updatePrim1").hide();
                                $("#primDelete1").hide();
                                $("#yinwubiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#ywjiantou").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#ywjiantou").show();
                                    $("#updatePrim1").show();
                                    $("#primDelete1").show();
                                }
                                $("#yinwubiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagyw1=0;
                                pagnumyw1=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if(MonitArr[i].substring(0, 3) == "PRI"){
                                        flagyw1++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsyw1[flagyw1]=Mon;
                                                if(flagyw1==1) {
                                                    $("#yinwubiao1 input").each(function (i, n) {
                                                        if (i > 3) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });

                                    }
                                }
                            }
                        }
                    });

                    ID = $("#fenziyangbenid1").val();
                    $("#danyangbenbiao1 input").each(function (i, n) {
                        if (i > 2) return;
                        $(this).val("");
                    });
                    $.ajax({
                        type: "get",
                        async: true,
                        url: "AllMonit.action?monitID=" + "MMR" + ID,
                        success: function (result) {
                            if (result == "00") {
                                return;
                            } else if (result.indexOf("SIF") < 0) {
                                $("#updateSample1").hide();
                                $("#sampleDelete1").hide();
                                $("#danyangbenbiao1 input").each(function (i, n) {
                                    $(this).attr("readonly","readonly");
                                });
                                $("#dybjiantou1").hide();
                            } else {
                                if ($("#user3").val() != "privilege") {
                                    $("#dybjiantou1").show();
                                    $("#updateSample1").show();
                                    $("#sampleDelete1").show();
                                }
                                $("#danyangbenbiao1 input").each(function (i, n) {
                                    $(this).removeAttr("readonly");
                                });
                                MonitArr = result.split(',');
                                flagdyb1=0;
                                pagnumdyb1=1;
                                for (var i = 0; i < MonitArr.length; i++) {
                                    if (MonitArr[i].substring(0, 3) == "SIF") {
                                        flagdyb++;
                                        $.ajax({
                                            type: "get",
                                            url: "ShowMessage.action?monitID=" + MonitArr[i],
                                            async: false,
                                            success: function (result) {
                                                var Mon = result.split(",");
                                                flagnumsdyb1[flagdyb1]=Mon;
                                                if(flagdyb1==1) {
                                                    $("#danyangbenbiao1 input").each(function (i, n) {
                                                        if (i > 2) return;
                                                        $(this).val(Mon[i]);
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });
                }
            });
        }
    });

    $('.ldyb-next-page').click(function(){
        if(pagnumdyb1==flagdyb1)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumsdyb1[pagnumdyb1+1];
            $("#danyangbenbiao1 input").each(function (i, n) {
                if (i > 2) return;
                $(this).val(ar[i]);
            });
            pagnumdyb1++;
        }
    });
    $('.ldyb-pre-page').click(function(){
        if(pagnumdyb1==1||pagnumdyb1==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsdyb1[pagnumdyb1-1];

            $("#danyangbenbiao1 input").each(function (i, n) {
                if (i > 2) return;
                else $(this).val(ar[i]);
            });
            pagnumdyb1--;
        }
    });

    $('.lyw-next-page').click(function(){
        if(pagnumyw1==flagyw1)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumsyw1[pagnumyw1+1];
            $("#yinwubiao1 input").each(function (i, n) {
                if (i > 3) return;
                $(this).val(ar[i]);
            });
            pagnumyw1++;
        }
    });
    $('.lyw-pre-page').click(function(){
        if(pagnumyw1==1||pagnumyw1==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsyw1[pagnumyw1-1];

            $("#yinwubiao1 input").each(function (i, n) {
                if (i > 3) return;
                else $(this).val(ar[i]);
            });
            pagnumyw1--;
        }
    });

    $('.lfz-next-page').click(function(){
        if(pagnumfz1==flagfz1)
        {
            alert("已经是最后一页了！");
        }
        else {

            var ar=flagnumsfz1[pagnumfz1+1];
            $("#lybfz").val(ar[1]);
            $("#fenziyangbenbiao1 input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val(ar[i]);
                }
                else {
                    if (i > 3) return;
                    else $(this).val(ar[i+1]);
                }
            });
            pagnumfz1++;
            var ID=$("#fenziyangbenid1").val();

            $("#yinwubiao1 input").each(function (i, n) {
                if (i > 3) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url:"AllMonit.action?monitID=MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("PRI") < 0) {

                    } else {
                        MonitArr = result.split(',');
                        flagyw1=0;
                        pagnumyw1=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if(MonitArr[i].substring(0, 3) == "PRI"){
                                flagyw1++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsyw1[flagyw1]=Mon;
                                        if(flagyw1==1) {
                                            $("#yinwubiao1 input").each(function (i, n) {
                                                if (i > 3) return;
                                                $(this).val(Mon[i]);
                                            });
                                        }
                                    }
                                });

                            }
                        }
                    }
                }
            });
            ID = $("#fenziyangbenid1").val();
            $("#danyangbenbiao1 input").each(function (i, n) {
                if (i > 2) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + "MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("SIF") < 0) {
                    } else {
                        MonitArr = result.split(',');
                        flagdyb1=0;
                        pagnumdyb1=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "SIF") {
                                flagdyb++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsdyb1[flagdyb1]=Mon;
                                        $("#danyangbenbiao1 input").each(function (i, n) {
                                            if (i > 2) return;
                                            $(this).val(Mon[i]);
                                        });
                                    }
                                });
                            }
                        }
                    }
                }
            });
        }
    });
    $('.lfz-pre-page').click(function(){
        if(pagnumfz1==1||pagnumfz1==0)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsfz1[pagnumfz1-1];

            $("#lybfz").val(ar[1]);
            $("#fenziyangbenbiao1 input").each(function (i, n) {
                if(i==0)
                {
                    $(this).val(ar[i]);
                }
                else {
                    if (i > 3) return;
                    else $(this).val(ar[i+1]);
                }
            });
            pagnumfz1--;
            var ID=$("#fenziyangbenid1").val();

            $("#yinwubiao1 input").each(function (i, n) {
                if (i > 3) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url:"AllMonit.action?monitID=MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("PRI") < 0) {

                    } else {
                        MonitArr = result.split(',');
                        flagyw1=0;
                        pagnumyw1=1;
                        flagnumsyw1={};
                        for (var i = 0; i < MonitArr.length; i++) {
                            if(MonitArr[i].substring(0, 3) == "PRI"){
                                flagyw1++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsyw1[flagyw1]=Mon;
                                        if(flagyw1==1) {
                                            $("#yinwubiao1 input").each(function (i, n) {
                                                if (i > 3) return;
                                                $(this).val(Mon[i]);
                                            });
                                        }
                                    }
                                });

                            }
                        }
                    }
                }
            });
            ID = $("#fenziyangbenid1").val();
            $("#danyangbenbiao1 input").each(function (i, n) {
                if (i > 2) return;
                $(this).val("");
            });
            $.ajax({
                type: "get",
                async: true,
                url: "AllMonit.action?monitID=" + "MMR" + ID,
                success: function (result) {
                    if (result == "00") {

                        return;
                    } else if (result.indexOf("SIF") < 0) {
                    } else {
                        MonitArr = result.split(',');
                        flagdyb1=0;
                        pagnumdyb1=1;
                        for (var i = 0; i < MonitArr.length; i++) {
                            if (MonitArr[i].substring(0, 3) == "SIF") {
                                flagdyb1++;
                                $.ajax({
                                    type: "get",
                                    url: "ShowMessage.action?monitID=" + MonitArr[i],
                                    async: false,
                                    success: function (result) {
                                        var Mon = result.split(",");
                                        flagnumsdyb1[flagdyb1]=Mon;
                                        $("#danyangbenbiao1 input").each(function (i, n) {
                                            if (i > 2) return;
                                            $(this).val(Mon[i]);
                                        });
                                    }
                                });
                            }
                        }
                    }
                }
            });
        }
    });


//单群体
    $('.show-dqt').click(function(){
        var ID = $("#yuhuowuid").val();

        $.ajax({
            type: "get",
            async: true,
            url: "AllMonit.action?monitID=" + ID,
            success: function (result) {
                if (result == "00") {

                    return;
                } else if (result.indexOf("CRD") < 0) {
                    alert("没有数据");
                } else {
                    MonitArr = result.split(',');

                    $("#danquntibiao").css({"display": "block"});
                    flagdqt=0;
                    for (var i = 0; i < MonitArr.length; i++) {
                        if (MonitArr[i].substring(0, 3) == "CRD") {
                            flagdqt++;
                            $.ajax({
                                type: "get",
                                url: "ShowMessage.action?monitID=" + MonitArr[i],
                                async: false,
                                success: function (result) {
                                    var Mon = result.split(",");
                                    flagnumsdqt[flagdqt]=Mon;
                                    if(flagdqt==1) {
                                        $("#danquntibiao input").each(function (i, n) {
                                            if (i > 10) return;
                                            $(this).val(Mon[i]);
                                        });
                                    }
                                }
                            });
                        }
                    }
                    pagnumdqt=1;
                    $("#danquntitou").html("第"+pagnumdqt+"页/共"+flagdqt+"页\n" );
                    $('#dqt').fadeIn();
                    $('#p-l-c-mask').fadeIn();

                }
            }
        });
    });
    $('#dqt .close').click(function(e){
        $("#danqunti").validate({}).resetForm();
        $('#dqt').hide();
        $('#yhw').hide();
        $('#p-l-c-mask').hide();
        if (buttonID == "caiyangshangbty") {
            $('#caiyangshangbty').click();
            //$("#wjid").html("网具编号："+$("#caiyangshang").html().substring(21,39)+" <span class=\"close glyphicon glyphicon-remove\"></span>");
        }
        else if (buttonID == "caiyangzhongbty") {
            $('#caiyangzhongbty').click();
        }
        else if (buttonID == "caiyangxiabty") {
            $('#caiyangxiabty').click();
        }
        else if (buttonID == "caiyanghunhebty") {
            $('#caiyanghunhebty').click();
        }
    });
    $('.dqt-next-page').click(function(){
        if(pagnumdqt==flagdqt)
        {
            alert("已经是最后一页了！");
        }
        else {
            var ar=flagnumsdqt[pagnumdqt+1];
            $("#danqunti").validate({}).resetForm();
            $("#danquntibiao input").each(function (i, n) {
                if (i > 10) return;
                $(this).val(ar[i]);
            });
            pagnumdqt++;
            $("#danquntitou").html("第"+pagnumdqt+"页/共"+flagdqt+"页\n" );

        }
    });
    $('.dqt-pre-page').click(function(){
        if(pagnumdqt==1)
        {
            alert("已经是第一页了！");
        }
        else {
            var ar=flagnumsdqt[pagnumdqt-1];
            $("#danqunti").validate({}).resetForm();
            $("#danquntibiao input").each(function (i, n) {
                if (i > 10) return;
                $(this).val(ar[i]);
            });
            pagnumdqt--;
            $("#danquntitou").html("第"+pagnumdqt+"页/共"+flagdqt+"页\n" );

        }
    });
});